068c22434907f28ab72c7f5f030c543ac9a777c7,test/src/org/exist/xquery/functions/validate/JaxpXsdCatalogTest.java,JaxpXsdCatalogTest,prepareResources,#,55
Before Change
public static void prepareResources() throws XMLDBException, IOException {
// Switch off validation
final Collection conf = createCollection(rootCollection, "system/config/db/parse");
storeResource(conf, "collection.xconf", noValidation.getBytes());
// Create filter
final Predicate<Path> filter = path -> FileUtils.fileName(path).endsWith(".xsd");
final Collection schemasCollection = createCollection(rootCollection, "parse/schemas");
final Path schemas = Paths.get("samples/validation/parse/schemas");
for (final Path file : FileUtils.list(schemas, filter)) {
final byte[] data = readFile(file);
storeResource(schemasCollection, FileUtils.fileName(file), data);
}
final Path catalog = Paths.get("samples/validation/parse");
final Collection parseCollection = createCollection(rootCollection, "parse");
final byte[] data = readFile(catalog, "catalog.xml");
storeResource(parseCollection, "catalog.xml", data);
final Path instance = Paths.get("samples/validation/parse/instance");
final Collection instanceCollection = createCollection(rootCollection, "parse/instance");
final byte[] valid = readFile(instance, "valid.xml");
storeResource(instanceCollection, "valid.xml", valid);
final byte[] invalid = readFile(instance, "invalid.xml");
storeResource(instanceCollection, "invalid.xml", invalid);
}
@Before
After Change
// Switch off validation
Collection conf = null;
try {
conf = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "system/config/db/parse");
ExistXmldbEmbeddedServer.storeResource(conf, "collection.xconf", noValidation.getBytes());
} finally {
if(conf != null) {
conf.close();
}
}
// Create filter
final Predicate<Path> filter = path -> FileUtils.fileName(path).endsWith(".xsd");
Collection schemasCollection = null;
try {
schemasCollection = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "parse/schemas");
final Path schemas = Paths.get("samples/validation/parse/schemas");
for (final Path file : FileUtils.list(schemas, filter)) {
final byte[] data = TestUtils.readFile(file);
ExistXmldbEmbeddedServer.storeResource(schemasCollection, FileUtils.fileName(file), data);
}
} finally {
if(schemasCollection != null) {
schemasCollection.close();
}
}
final Path catalog = Paths.get("samples/validation/parse");
Collection parseCollection = null;
try {
parseCollection = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "parse");
final byte[] data = TestUtils.readFile(catalog, "catalog.xml");
ExistXmldbEmbeddedServer.storeResource(parseCollection, "catalog.xml", data);
} finally {
if(parseCollection != null) {
parseCollection.close();
}
}
final Path instance = Paths.get("samples/validation/parse/instance");
Collection instanceCollection = null;
try {
instanceCollection = existEmbeddedServer.createCollection(existEmbeddedServer.getRoot(), "parse/instance");
final byte[] valid = TestUtils.readFile(instance, "valid.xml");
ExistXmldbEmbeddedServer.storeResource(instanceCollection, "valid.xml", valid);
final byte[] invalid = TestUtils.readFile(instance, "invalid.xml");
ExistXmldbEmbeddedServer.storeResource(instanceCollection, "invalid.xml", invalid);
} finally {
if(instanceCollection != null) {
instanceCollection.close();